<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h3 v-show="tab==1" >首页</h3>
        <h3 v-show="tab==2" >新闻</h3>
        <h3 v-show="tab==3">个人中心</h3>
        <button  @click="tabChange" data-id="1">首页</button>
        <button  @click="tabChange"  data-id="2">新闻</button>
        <button  @click="tabChange"  data-id="3">个人中心</button>
    </div>
    <script src="vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                tab:1,
            },
            methods:{
                tabChange:function(e){
                    // console.log(e);
                    // console.log(this);
                    // vm.tab 等同于 this.tab
                   this.tab = e.target.dataset.id;

                }
            }
        });
    </script>
</body>
</html>